import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ShiftForm, ShiftQuery, ShiftVO } from '@/api/attendance/setting/shift/types';

/**
 * 查询考勤班次列表
 * @param query
 * @returns {*}
 */

export const listShift = (query?: ShiftQuery): AxiosPromise<ShiftVO[]> => {
  return request({
    url: '/attendance/shift/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询考勤班次详细
 * @param id
 */
export const getShift = (id: string | number): AxiosPromise<ShiftVO> => {
  return request({
    url: '/attendance/shift/' + id,
    method: 'get'
  });
};

/**
 * 新增考勤班次
 * @param data
 */
export const addShift = (data: ShiftForm) => {
  return request({
    url: '/attendance/shift',
    method: 'post',
    data: data
  });
};

/**
 * 修改考勤班次
 * @param data
 */
export const updateShift = (data: ShiftForm) => {
  return request({
    url: '/attendance/shift',
    method: 'put',
    data: data
  });
};

/**
 * 删除考勤班次
 * @param id
 */
export const delShift = (id: string | number | Array<string | number>) => {
  return request({
    url: '/attendance/shift/' + id,
    method: 'delete'
  });
};

export const listShiftSegments = (query?: ShiftQuery): AxiosPromise<any[]> => {
  return request({
    url: '/attendance/shift/segments',
    method: 'get',
    params: query
  });
};
